package com.bootdo.cms.service.impl;

import com.bootdo.cms.dao.MemberDao;
import com.bootdo.cms.domain.MemberDO;
import com.bootdo.cms.service.MemberService;
import com.bootdo.cms.vo.MemberVO;
import com.bootdo.common.utils.MD5Utils;
import com.bootdo.common.utils.ShiroUtils;
import com.bootdo.system.domain.UserDO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import java.util.Objects;

/**
 * @author KonBAI
 * @version 1.0
 * Create by 2019/12/18 03:14
 */
@Service
public class MemberServiceImpl implements MemberService {
	@Autowired
	private MemberDao memberMapper;
	
	@Override
	public MemberDO get(Long memberId){
		return memberMapper.get(memberId);
	}

	@Override
	public MemberDO getByUsername(String username) {
		return memberMapper.getByUsername(username);
	}
	
	@Override
	public List<MemberDO> list(Map<String, Object> map){
		return memberMapper.list(map);
	}
	
	@Override
	public int count(Map<String, Object> map){
		return memberMapper.count(map);
	}
	
	@Override
	public int save(MemberDO member){
		return memberMapper.save(member);
	}
	
	@Override
	public int update(MemberDO member){
		return memberMapper.update(member);
	}

	@Override
	public int remove(Long memberId){
		return memberMapper.remove(memberId);
	}
	
	@Override
	public int batchRemove(Long[] memberIds){
		return memberMapper.batchRemove(memberIds);
	}

    @Override
    public int resetPwd(MemberVO memberVO) {
		MemberDO memberDO = get(memberVO.getMemberDO().getMemberId());
		memberDO.setPassword(MD5Utils.encrypt(memberDO.getUsername(), memberVO.getPwdNew()));
		return memberMapper.update(memberDO);
    }

}
